﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace launcher.Common
{
    internal static class StringUtils
    {
        public static string[] AppendItemIfNotContains(string[] array, string str)
        {
            if (str == null)
            {
                return array;
            }

            if ((array == null) || (array.Length == 0))
            {
                return new string[] { str };
            }

            foreach (var item in array)
            {
                if (item.Equals(str))
                {
                    return array;
                }
            }

            var list = new List<string>(array);
            list.Add(str);
            list.Sort();
            return list.ToArray();
        }
    }
}
